/**
 * 
 */
package com.tvshows.front.view.dialog;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;

import com.tvshows.front.ui.dialog.DialogUI;
import com.tvshows.front.view.labels.FrontButton;
import com.tvshows.structure.log.LoggingTreatment;

/**
 * @author Tangi Midy
 */
public class DialogLogView
    extends Composite
    implements DialogUI
{

    /**
     * LogList
     */
    private List logList;

    /**
     * The ok button
     */
    private FrontButton okButton;

    /**
     * Constructeur
     * 
     * @param parent parent composite
     * @param style style
     */
    public DialogLogView( Composite parent, int style )
    {
        super( parent, style );
        initComponents();
        loadLog();
    }

    /**
     * Initializes components
     */
    private void initComponents()
    {

        setSize( 600, 350 );
        logList = new List( this, SWT.V_SCROLL );
        logList.setBounds( 10, 10, 570, 300 );

        okButton = new FrontButton( this, SWT.NONE );
        okButton.setText( "Fermer le log" );
        okButton.setBounds( 10, 320, 100, 25 );
        okButton.addListener( SWT.Selection, new Listener()
        {

            @Override
            public void handleEvent( Event e )
            {
                getShell().dispose();
            }
        } );
    }

    public void loadLog()
    {
        for ( String logMessage : LoggingTreatment.getInstance().getLogMessages() )
        {
            logList.add( logMessage );
        }
    }

    @Override
    public void initFormData()
    {

    }

    @Override
    public void initComposites()
    {

    }
}
